package com.changpay.zywy.adapter

import android.content.Context
import android.widget.CheckBox
import android.widget.LinearLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.changpay.zywy.R
import com.changpay.zywy.bean.MyMachineToolsList

/**
 * Created by chenxz on 2018/4/22.
 */
class SelectSnAdapter(private val context: Context?, datas: MutableList<MyMachineToolsList.ListBean>) :
    BaseQuickAdapter<MyMachineToolsList.ListBean, BaseViewHolder>(R.layout.item_select_sn, datas) {
    override fun convert(helper: BaseViewHolder?, item: MyMachineToolsList.ListBean?) {
        item ?: return
        helper ?: return
        helper.setText(R.id.tv_sn_number, item.sn_code)
        helper.setChecked(R.id.cb_select, item.isSelect)
        val ll_content = helper.getView<LinearLayout>(R.id.ll_content)
        val cb_select = helper.getView<CheckBox>(R.id.cb_select)
        ll_content.setOnClickListener {
            item.isSelect = !item.isSelect
            helper.setChecked(R.id.cb_select, item.isSelect)
        }

        cb_select.setOnClickListener {  item.isSelect = !item.isSelect
            helper.setChecked(R.id.cb_select, item.isSelect) }
    }

}
